import reactive from "./reactive.js";
const arr = [{ a: 1 }, 1, 3, 4];
const state = reactive(arr);
// const test = reactive(state);
// console.log(test === state);
// console.log(arr);

// 写入数据相关测试
function set() {
  // state[3] = 2; // length被隐式改动
  // Object.defineProperty(state, "5", {
  //   value: 2,
  // }); // length被隐式改动
  // state.length = 5; // 增大length，没问题
  // state.length = 2; // 减小length，下标为2的元素被自动删除
  // 改变数组的方法
  // state.shift();
  // state.unshift(1)
  // state.pop();
  state.push(1);
  // state.reverse();
  // state.splice(1, 1);
  // state.sort((a, b) => a - b);
  console.log(arr);
}

set();

let a = arr[0];
// 读取数据相关测试
function get() {
  // state.at[0];
  // state[0]
  // for (let i = 0; i < state.length; i++) {
  //   state[i]
  // }
  // for (const i in state) { // 读取 in关键字 相关信息
  //   state[i]
  // }
  // for (const val of state) { // 读取 迭代器 相关信息
  //   val;
  // }
  console.log("includes", state.includes(a));
  console.log(
    "find",
    state.find((item) => item === a)
  );
  console.log("findLast", state.findLast((item) => item === a) === state[0]);
  console.log(
    "findIndex",
    state.findIndex((item) => item === a)
  );
  console.log(
    "findLastIndex",
    state.findLastIndex((item) => item === a)
  );
  console.log("-------------------------------------------");
  console.log("indexOf", state.indexOf(a));
  console.log("lastIndexOf", state.lastIndexOf(a));
  console.log(
    "some",
    state.some((item) => item === a)
  );
  console.log(
    "every",
    state.every((item) => item === a)
  );
  // state.join("");
}

// get();
